
<template>
  <div>
    饿了么UI后台组件
  </div>
</template>

<script>
  import { get } from "@/api/common";
  export default {
    name: "admin_ele",
    data() {
      return {
        items: [],
      }
    },
    mounted() {
      this.getLoginUser()
    },
    methods: {
      // 获得当前用户
      getLoginUser() {
          let that = this;
          this.$http.get('/api/getCurrentUser', {})
          .then(function (res) {
            var data = res.data;
            if(data.userId!='') {
              that.userId = data.userId;
              that.userRole = data.userRole;
              that.$message('LoginId = '+that.userId+' --- 角色 = '+that.userRole);
              that.getLists();
            }
            else {
              that.$message('获得当前登录用户失败...');
            }
          })
          .catch(function (error){
              that.$message('获得当前登录用户失败...');
          });
      },
      // 调用api获得列表
      getLists(){
        let params={
            '[]': {
                'TableName': {'@column': 'id,name'}
            }
        };
        let that = this;
        get(params)
          .then(function (res) {
            that.items = res["[]"];
          })
          .catch(function (error){
              console.log(error);
          });
      },
    }
  }
</script>

<style scoped>

</style>
  